//
//  LOLSortCollectionCell.m
//  LOLXXbox
//
//  Created by dllo on 16/2/29.
//  Copyright © 2016年 Grasstrio. All rights reserved.
//

#import "LOLSortCollectionCell.h"
#import <Masonry.h>
#import <UIImageView+WebCache.h>
@implementation LOLSortCollectionCell

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.imageViews = [[UIImageView alloc] init];
    
        [self addSubview:self.imageViews];
        
        self.label = [[UILabel alloc] init];
      
        self.label.font = [UIFont systemFontOfSize:15];
        self.label.textAlignment = NSTextAlignmentCenter;
        [self addSubview:self.label];
    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes{
    
    [self.imageViews mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(5);
        make.left.equalTo(self.contentView).offset(5);
        make.right.equalTo(self.contentView).offset(-5);
        make.bottom.equalTo(self.contentView).offset(-30);
//        make.height.equalTo(@(self.contentView));
    }];
    
    [self.label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.contentView).offset(-5);
        make.left.equalTo(self.contentView).offset(5);
        make.right.equalTo(self.contentView).offset(-5);
        make.top.equalTo(self.imageViews.mas_bottom).offset(5);
    }];
    
}

- (void)setSubModel:(LOLSubModel *)subModel{
    _subModel = subModel;
    [self.imageViews sd_setImageWithURL:[NSURL URLWithString:self.subModel.icon]];
    self.label.text = self.subModel.name;
}

@end
